package com.wxg.seata.rest;

import com.wxg.common.core.base.CommonResult;
import com.wxg.seata.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author void
 * @date 2021/7/7 16:36
 * @desc
 */
@RestController
@RequestMapping("/account")
public class AccountController {
    
    @Autowired
    private AccountService accountService;

    /**
     * 扣减余额
     * @param userId
     * @param money
     * @return
     */
    @GetMapping("/decrease")
    public CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money")BigDecimal money){
        accountService.decrease(userId, money);
        return new CommonResult("扣减账户余额成功", 200);
    }
}
